package com.zero.insp.shiro;

import org.apache.shiro.crypto.hash.Md5Hash;
import org.apache.shiro.crypto.hash.SimpleHash;

import java.util.UUID;

/**
 * @author : pengjie
 * @PackageName : com.paas.demo.shiro
 * @Description : TODO
 * @email : 627799251@qq.com
 * @Date : 2019/1/21 11:19
 */
public class ShiroPasswordHelper {

    public static String genPasswdSalt() {
        String source = UUID.randomUUID().toString().replace("-", "").substring(0, 20);
        return source;
    }

    public static String encodePassword(String password, String salt) {
        return new SimpleHash(Md5Hash.ALGORITHM_NAME, password, salt, 1024).toHex();
    }

    public static void main(String[] args) {
        String salt = "659e26af9d1545008eeb";
        System.out.println("salt = " + salt);

        System.out.println("password = " + encodePassword("1234", salt));
    }
}
